﻿using System;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;

namespace QLKHACHHANG.Utilities
{
    class Utilities
    {
        // ma hoa chuoi thanh md5
        public static string StringToMD5(string text)
        {
            if (!text.Equals(""))
            {
                var md5Hasher = new MD5CryptoServiceProvider();
                byte[] bs = Encoding.UTF8.GetBytes(text);
                bs = md5Hasher.ComputeHash(bs);
                var s = new StringBuilder();
                foreach (byte b in bs)
                {
                    s.Append(b.ToString("x2"));
                }
                return s.ToString();
            }
            else return text;
           
        }
        // tim control bang ten
        private Control FindControl(Control myControl, string childname)
        {
            Control result = null;
            if (myControl.Name.Equals(childname))
            {
                myControl.Enabled = false;
                return myControl;
            }
            foreach (Control myChild in myControl.Controls)
            {
                result = FindControl(myChild, childname);
                if (result != null)
                {
                    break;
                }
            }
            return result;
        }
    }
}
